<<<<<<< HEAD
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); 
/*
 * 宝付托管加密类
 * */
class MyAES { 
	
 /*
  * 加密
  * */	
 public function encryptString($input, $key,$iv) {
   $encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $input, MCRYPT_MODE_CBC, $iv);
   $data = bin2hex($encrypted);
   return $data;
  }
  /*
  * 解密
  * */	
 public function decryptString($sStr, $sKey,$iv) {
    $data = MyAES::hex2bin($sStr);
    return mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $sKey, $data, MCRYPT_MODE_CBC, $iv);
  }
 
 public static function hex2bin($hexdata) {
        $bindata = '';
        $length = strlen($hexdata);
        for ($i=0; $i < $length; $i += 2)
        {
            $bindata .= chr(hexdec(substr($hexdata, $i, 2)));
        }
        return $bindata;
   }
=======
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); 
/*
 * 宝付托管加密类
 * */
class MyAES { 
    
 /*
  * 加密
  * */	
 public function encryptString($input, $key,$iv) {
   $encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $input, MCRYPT_MODE_CBC, $iv);
   $data = bin2hex($encrypted);
   return $data;
  }
  /*
  * 解密
  * */	
 public function decryptString($sStr, $sKey,$iv) {
    $data = MyAES::hex2bin($sStr);
    return mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $sKey, $data, MCRYPT_MODE_CBC, $iv);
  }
 
 public static function hex2bin($hexdata) {
        $bindata = '';
        $length = strlen($hexdata);
        for ($i=0; $i < $length; $i += 2)
        {
            $bindata .= chr(hexdec(substr($hexdata, $i, 2)));
        }
        return $bindata;
   }
>>>>>>> d47623b610d79a4eeb489500830c00d70933f414
}